﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WMP
{
    public class ObjListe
    {
        public string FilePath = "";
        public string FileName = "";
        public string Artist = "";
        public string cd = "";
        public string time = "";

        public ObjListe()
        {

        }

        public ObjListe(string path)
        {
            ID3V2 id3v2 = new ID3V2();
            List<ID3V2.Info> list;
            Parseur getname = new Parseur();
            int i = 0;

            try
            {
                id3v2.readInfo(path);
                list = id3v2.getList();
                while (i < list.Count)
                {
                    feed(list.ElementAt(i));
                    //MessageBox.Show(i.ToString());
                    i += 1;
                }
            }
            catch
            {

            }
            finally
            {
                FileName = getname.parser(path);
            }

            //MessageBox.Show(name);*/
        }

        private void feed(ID3V2.Info info)
        {
            int i = 1;
           
                while (i < info.len)
                {
                    if (info.tipe == "artist")
                        Artist += info.info[i];
                    else if (info.tipe == "album")
                        cd += info.info[i];
                    else if (info.tipe == "duree")
                        time += info.info[i];
                    else if (info.tipe == "name")
                        FileName += FileName;
                    i += 1;
                }
        }

        public string Nom { get { return FileName; } set { FileName = value; } }
        public string Artiste { get { return Artist; } set { Artist = value; } }
        public string Album { get { return cd; } set { cd = value; } }
        public string Duree { get { return time; } set { time = value; } }
    }
}
